package com.example.demo.controller;


import com.example.demo.domain.User;

import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//WEB层
@RestController()//返回comment是能以json方式返回
@RequestMapping("Api")
public class UserController {
    @Autowired
    private UserService userService;





    //查询
    @GetMapping("/get/{id}")
    //PathVariable根据路径得到id
    public User findById(@PathVariable("id") Integer id){
        User user=userService.findById(id);
        return  user;
    }




}
